/* eslint-disable */
//第三方类库加载管理js，方便切换lib
var configLibs = [ 
	"static/js/moment.js", 
	"h5player.min.js",
];

//内部处理方法
;
(function() {
	var r = new RegExp('(^|(.*?\\/))(lib.js)(\\?|$)'),
		s = document.getElementsByTagName('script'),
		targetScript
	for (var i = 0; i < s.length; i++) {
		var src = s[i].getAttribute('src')
		if (src) {
			var m = src.match(r)
			if (m) {
				targetScript = s[i]
				break
			}
		}
	}

	// cssExpr 用于判断资源是否是css
	var cssExpr = new RegExp('\\.css')

	function inputLibs(list, baseUrl, ix) {
		if (list == null || list.length === 0 || list.length <= ix) {
			return
		}
		var url = list[ix];
		if (!url.startsWith("http") && !url.startsWith("//:")) {
			url = baseUrl + url
		}
		let item;
		if (cssExpr.test(url)) {
			item = document.createElement("link");
			item.setAttribute("href", url);
			item.setAttribute("rel", "stylesheet");
		} else {
			item = document.createElement("script");
			item.setAttribute("src", url);
			item.setAttribute("type", "text/javascript");

		}
		document.head.appendChild(item);
		item.addEventListener("load", (e) => {
			inputLibs(list, baseUrl, ix + 1);
		});
	}

	var done = false
	//加载类库资源文件
	function load() {
		var arrInclude = (targetScript.getAttribute('include') || '').split(',')
		var libpath = targetScript.getAttribute('src') || ''
		var i = libpath.lastIndexOf('/');
		if (i > -1) {
			libpath = libpath.substring(0, i+1);
		}
		if (done) {
			return;
		}
		done = true;
		inputLibs(configLibs, libpath, 0)
	}

	load()
})()